package com.sgb.kjwl.view.widget.pick;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.pick.PickRecordCount;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;

/**
 * 招标详情-业主交互
 */
public class TenderDetailsPopWindow extends BasePopWindow {

    private CallBack callBack;
    private PickRecordCount pickRecordCount;
    private TextView tbjlNum;
    private TextView bmjlNum;
    private TextView sqjlNum;
    private TextView yqjlNum;
    private TextView jbjjNum;
    private TextView khhxNum;

    public TenderDetailsPopWindow(Context context, int dir, PickRecordCount pickRecordCount) {
        super(context, dir);
        this.pickRecordCount = pickRecordCount;
        setTextData();
    }

    @Override
    protected int popLayout() {
        return R.layout.tender_details_popwindow;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        tbjlNum = holder.getPop().findViewById(R.id.tbjl_num);
        bmjlNum = holder.getPop().findViewById(R.id.bmjl_num);
        sqjlNum = holder.getPop().findViewById(R.id.sqjl_num);
        yqjlNum = holder.getPop().findViewById(R.id.yqjl_num);
        jbjjNum = holder.getPop().findViewById(R.id.jbjj_num);
        khhxNum = holder.getPop().findViewById(R.id.khhx_num);

        holder.getPop().findViewById(R.id.line_jqjl).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.onLoad(3);
            }
        });
        holder.getPop().findViewById(R.id.line_bmjl).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.onLoad(4);
            }
        });
        holder.getPop().findViewById(R.id.line_tbjl).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.onLoad(5);
            }
        });
        holder.getPop().findViewById(R.id.line_sqjl).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.onLoad(8);
            }
        });
        holder.getPop().findViewById(R.id.line_khhx).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.onLoad(6);
            }
        });
        holder.getPop().findViewById(R.id.line_jbjj).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callBack.onLoad(7);
            }
        });
        holder.getPop().findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    private void setTextData() {
        if (pickRecordCount != null && pickRecordCount.getApplyNum() > 0) {
            bmjlNum.setVisibility(View.VISIBLE);
            bmjlNum.setText(String.valueOf(pickRecordCount.getApplyNum()));
        }
        if (pickRecordCount != null && pickRecordCount.getApprovalNum() > 0) {
            sqjlNum.setVisibility(View.VISIBLE);
            sqjlNum.setText(String.valueOf(pickRecordCount.getApprovalNum()));
        }
        if (pickRecordCount != null && pickRecordCount.getInvitationNum() > 0) {
            yqjlNum.setVisibility(View.VISIBLE);
            yqjlNum.setText(String.valueOf(pickRecordCount.getInvitationNum()));
        }
        if (pickRecordCount != null && pickRecordCount.getOfferNum() > 0) {
            tbjlNum.setVisibility(View.VISIBLE);
            tbjlNum.setText(String.valueOf(pickRecordCount.getOfferNum()));
        }
        if (pickRecordCount != null && pickRecordCount.getReportNum() > 0) {
            jbjjNum.setVisibility(View.VISIBLE);
            jbjjNum.setText(String.valueOf(pickRecordCount.getReportNum()));
        }
        if (pickRecordCount != null && pickRecordCount.getInquiryNum() > 0) {
            khhxNum.setVisibility(View.VISIBLE);
            khhxNum.setText(String.valueOf(pickRecordCount.getInquiryNum()));
        }
    }

    public void setCallBack(CallBack callBack) {
        this.callBack = callBack;
    }

    public interface CallBack {
        void onLoad(int i);
    }
}
